package controller

import (
	"context"
	pb "gitee.com/micro-services/protocol/tag/api"
	"micro.tag.client/ao"
)

type TagController struct{}

func (tc *TagController) CreateHotelTag(ctx context.Context, r *pb.APICreateHotelTagReq, w *pb.APICreateHotelTagRsp) error {
	rsp, err := ao.CreateHotelTag(ctx, r)
	if err != nil {
		return err
	}

	w.Msg = rsp.Msg
	w.RetCode = rsp.RetCode
	return nil
}

func (tc *TagController) DeleteHotelTag(ctx context.Context, r *pb.APIDeleteHotelTagReq, w *pb.APIDeleteHotelTagRsp) error {
	rsp, err := ao.DeleteHotelTag(ctx, r)
	if err != nil {
		return err
	}

	w.Msg = rsp.Msg
	w.RetCode = rsp.RetCode
	return nil
}

func (tc *TagController) HotelTags(ctx context.Context, r *pb.APIHotelTagsReq, w *pb.APIHotelTagsRsp) error {
	rsp, err := ao.HotelTags(ctx, r)
	if err != nil {
		return err
	}

	w.Tag = rsp.Tag
	return nil
}

func (tc *TagController) CreateRoomTag(ctx context.Context, r *pb.APICreateRoomTagReq, w *pb.APICreateRoomTagRsp) error {
	rsp, err := ao.CreateRoomTag(ctx, r)
	if err != nil {
		return err
	}

	w.Msg = rsp.Msg
	w.RetCode = rsp.RetCode
	return nil
}

func (tc *TagController) DeleteRoomTag(ctx context.Context, r *pb.APIDeleteRoomTagReq, w *pb.APIDeleteRoomTagRsp) error {
	rsp, err := ao.DeleteRoomTag(ctx, r)
	if err != nil {
		return err
	}

	w.Msg = rsp.Msg
	w.RetCode = rsp.RetCode
	return nil
}

func (tc *TagController) RoomTags(ctx context.Context, r *pb.APIRoomTagsReq, w *pb.APIRoomTagsRsp) error {
	rsp, err := ao.RoomTags(ctx, r)
	if err != nil {
		return err
	}

	w.Tag = rsp.Tag
	return nil
}
